﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;

namespace CSEPT.Models
{
    public class ViewModel
    {
        public User CurrUser;
        public bool isLoggedIn;
        public DAL dal;
        public string PageMessage;
        public string PageMessageType;
        public ViewModel()
        {
            CurrUser = new User();
            isLoggedIn = false;
            dal = new DAL();
            if (System.Web.HttpContext.Current.Session["LoginID"] != null)
            {
                CurrUser = dal.GetUser(Convert.ToInt32(System.Web.HttpContext.Current.Session["LoginID"]));
                isLoggedIn = true;
            }
        }
    }
}
namespace CSEPT
{
    public class LoggedInAttribute : ActionFilterAttribute
    {
        public override void OnActionExecuting(ActionExecutingContext aec)
        {
            if (System.Web.HttpContext.Current.Session["LoginID"] != null)
            {

            }
            else
            {
                aec.Result = new RedirectResult("/Index/IndexInfo?Message=You%20Must%20be%20logged%20in%20to%20do%20that&Type=warning");
            }
        }
    }
}